﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ASmile.Com
{
    public interface IAppInit
    {
        /// <summary>
        /// 初始化通知
        /// </summary>
        event Action<string> OnNotify;
        /// <summary>
        /// 初始化操作
        /// </summary>
        void Init();
    }

    /// <summary>
    /// 应用初始化
    /// </summary>
    public class AppInit : IAppInit
    {
        ///// <summary>
        ///// 当初始化时触发
        ///// </summary>
        //public static event Action OnInit;

        //public static void SetConfig(ConfigCom config)
        //{
        //    ConfigCom.Set(config);
        //    OnInit?.Invoke();
        //}
        public event Action<string> OnNotify;

        public void NotifyMsg(string msg)
        {
            OnNotify?.Invoke(msg);
        }

        public void Init()
        {
#if NETSTANDARD
            //ConfigHelper.GetConfigObject

#else
            var config = ConfigHelper.GetAppSettings<ConfigCom>();
            ConfigCom.Set(config);
#endif

            OnNotify?.Invoke("");

        }
    }
}
